<?php
namespace app\index\controller;
use think\Controller;
use think\Request;
use think\Db;

class Common extends Controller
{
	public $req;
	function __construct() {
		parent::__construct();
		$this->req = Request::instance();

        // 判断当前控制器, 使相应导航高亮
		$con = __CLASS__;
        $arr = explode('\\', $con);
        $this->assign('_class', strtolower($arr[3]));

		/**
		 * 对于导航高亮起作用(不能删)
		 */
        $index = '';
        $this->assign('index', $index);
        $nav = '';
        $this->assign('nav', $nav);
        $cid = '';
        $this->assign('cid', $cid);

        

        // 新闻分类
        $nCategory = Db::query("SELECT * FROM `news_categorys`");
        $this->assign('nCategory', $nCategory);

        

        // 文章分类
        $categroy_list = model('admin/ArticleCategorys')->where('is_navigation',1)->select();
        foreach ($categroy_list as $key => $value) {
            // $categoryList[] = [];
            $categoryList[$key]['id'] = $value['id'];
            $categoryList[$key]['name'] = $value['name'];
            $categoryList[$key]['article'] = model('admin/Articles')->where(
                ['cid'=>$value['id'],'status'=>1]
            )->select();
        }
        $this->assign('categoryList', $categoryList);

        // 系统常量
        $system_param = json_decode(Db::table('web_config')->where('id',1)->value('systemBaseParams'),true);
        $this->assign('system_param', $system_param);


	}


}
